import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '新版思政刷题'
    }
  },
  {
    path: '/recite',
    name: 'Recite',
    component: () => import('../views/Recite.vue'),
    meta: {
      title: '思政刷题'
    }
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('../views/Search.vue'),
    meta: {
      title: '搜索'
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  to.meta.title && (document.title = to.meta.title);
  next()
});

export default router
